const GET = 'GET';
const POST = 'POST';
const PUT = 'PUT';
const FORM = 'FORM';
const DELETE = 'DELETE';
var  myURL = 'https://xtcee.xyz:8080/appDevice/postApi/' //// url: 'https://127.0.0.1:8080/appDevice/postApi/', 
//var  myURL = 'https://101.42.230.8:8080/appDevice/postApi/' //// url: 'https://127.0.0.1:8080/appDevice/postApi/', 
const baseURL = 'https://xtcee.xyz:8080/';

function request(method, url, data) {
    return new Promise(function(resolve, reject) {
        let header = {
            'content-type': 'application/json',
        };
        wx.request({
            url: myURL,
            method: method,
            data: {
                    Topic   :123, //由用户设置的账号密码
                    payload : 123, //负载 要发送的具体数据内容
                  },
            header: header,
            success(res) {
                //请求成功
                //判断状态码---errCode状态根据后端定义来判断
                if (res.data.errCode == 0) {
                    resolve(res);
                } else {
                    //其他异常
                    reject('运行时错误,请稍后再试');
                }
            },
            fail(err) {
                //请求失败
                reject(err)
            }
        })
    })
}

//衔接上面代码


const API = {
  getOpenid: (data) => request(POST, `jsapi/mini?jsCode=${data}`),
};
module.exports = {
  API: API
} 

